package Utils;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2024/12/05
 * @description 自定义callback对象
 * 自定义 methodInterceptor
 */
public class MyMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        // o 目标对象，method目标方法，objects参数
        long begin = System.currentTimeMillis();
        Object value = methodProxy.invokeSuper(o, objects);
        long end = System.currentTimeMillis();
        System.out.println("耗时：" + (end - begin) + "毫秒");
        return value;
    }
}
